/* SVN Info:
 * $HeadURL: http://jkad.googlecode.com/svn/tags/JKad_TCC_Prototype/src/jkad/facades/user/NetLocation.java $
 * $LastChangedRevision: 54 $
 * $LastChangedBy: polaco $                             
 * $LastChangedDate: 2006-11-13 02:11:22 +0000 (Mon, 13 Nov 2006) $  
 */
package jkad.facades.user;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class NetLocation
{
    private InetAddress ip;
    private Integer port;
    
    public NetLocation(String ip, Integer port) throws UnknownHostException
    {
        this(InetAddress.getByName(ip), port);
    }
    
    public NetLocation(InetAddress ip, Integer port)
    {
        this.ip = ip;
        this.port = port;
    }

    public InetAddress getIP()
    {
        return ip;
    }

    public void setIP(InetAddress ip)
    {
        this.ip = ip;
    }
    
    public String getStringIP()
    {
        String ipAddress = ip.toString();
        if(ipAddress.indexOf('/') == 0)
            ipAddress = ipAddress.substring(1);
        return ipAddress;
    }

    public Integer getPort()
    {
        return port;
    }

    public void setPort(Integer port)
    {
        this.port = port;
    }
    
    public String toString()
    {
        return this.getStringIP() + ":" + this.getPort();
    }

}